package com.funtl.itoken.common.hystrix;

import com.funtl.itoken.common.constants.HttpStatusConstants;
import com.funtl.itoken.common.dto.BaseResult;
import com.funtl.itoken.common.utils.MapperUtils;
import com.google.common.collect.Lists;

/**
 * 通用的熔断方法
 */
public class Fallback {
    public static String badGateWay(){
        BaseResult.Error error = new BaseResult.Error();
        error.setField(HttpStatusConstants.BAD_GATEWAY.getStatus()+"");
        error.setMessage(HttpStatusConstants.BAD_GATEWAY.getContent());
        BaseResult baseResult = BaseResult.notOk(Lists.newArrayList(error));
        try {
            return MapperUtils.obj2json(baseResult);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
